//
//  VoiceRecordView.swift
//  JiaoZiTaxi
//
//  Created by Hu Gang on 2022/11/28.
//

import SwiftUI

struct VoiceRecordView: View {
    @State var length: Double = 0
    var body: some View {
        VStack(alignment: .center) {
            Spacer()

            HStack {
                Spacer()
                VStack(alignment: .center){
                    AnimatedWaveformView(color:.black)
                        .scaledToFit()
                        .frame(width:120 + length,height:76 + length / 2)
                        .padding(.horizontal,10)
                        .padding(.vertical,8)
                        .foregroundColor(.black)
                        .background {
                            background
                        }
                    Text("正在录音")
                      .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                      .foregroundColor(Color("chat_me_background"))
                      .padding(.vertical,5)
                }.padding()
                Spacer()
            }

            Spacer()
        }.background(
            Color(hex: "00333333")
        )

    }

    struct Arrow: View {
        var body: some View {
            Path { path in
                path.move(to: .init(x: 6, y: 14))
                path.addLine(to: .init(x: 6, y: 26))
                path.addLine(to: .init(x: 0, y: 26))
                path.addLine(to: .init(x: 6, y: 14))
            }
            .fill(Color("chat_me_background"))
            .frame(width: 6,height:30)
        }
    }

    private var background: some View {
        RoundedRectangle(cornerRadius: 4)
            .foregroundColor(Color("chat_me_background"))
    }
}

struct VoiceRecordView_Previews: PreviewProvider {
    static var previews: some View {
        VoiceRecordView()
    }
}
